﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RpcGenerator
{
    class RpcGeneratorHelper
    {
        public static string GetInvokerName(Type type)
        {
            return type.Name + "_Invoker";
        }

        public static string GetProxyName(Type type)
        {
            string name = type.Name;
            if (name[0] == 'I')
                name = name.Substring(1);
            name += "Proxy";
            return name;
        }

        public static string GetParameterTypeName(Type type)
        {
            if (MessageFieldDescription.IsGenericType(type))
            {
                return "Array";
            }
            else if(MessageFieldDescription.IsPrimitiveType(type))
            {
                if (type == typeof(string))
                {
                    return "string";
                }

                if (type == typeof(float) || type == typeof(double))
                {
                    return "Number";
                }

                if (string.Equals(type.FullName, "System.Void"))
                {
                    return "void";
                }
                else
                {
                    return "int";
                }
            }
            else
            {
                return type.Name;
            }
        }
    }
}
